package com.ds.core.support.freemarker;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.view.freemarker.FreeMarkerView;
public class FreeMarkerViewExtend extends FreeMarkerView {
	private static Log logger = LogFactory.getLog(FreeMarkerViewExtend.class);

	@Override
	protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request){
		
		try {
			super.exposeHelpers(model, request);
		} catch (Exception e) {
			logger.error("FreeMarkerViewExtend 加载父类出现异常。请检查。\n"+e);
		}
		model.put("contextPath", request.getContextPath());
//		model.putAll(Freemarker.initMap);
//		UUser token = TokenManager.getToken();
		//String ip = IPUtils.getIP(request);
//		if(TokenManager.isLogin()){
//			model.put("token", token);//登录的token
//		}
		model.put("_time", new Date().getTime());
		model.put("NOW_YEAY", "2017");//今年
		
		model.put("_v", "testversion");//版本号，重启的时间
		model.put("cdn", "testdomain");//CDN域名
		model.put("basePath",request.getContextPath() );//base完整目录。
		//request.getScheme()+"://"+request.getServerName()+":"+ request.getServerPort() + request.getContextPath()
	}
}
